// 导出所有类型定义
export * from './common';
export * from './user';
export * from './travel';
export * from './audit';
export * from './wantGo';

export type UserRole = 'admin' | 'user';

export interface User {
  id: string;
  username: string;
  email?: string;
  role: UserRole;
  createdAt?: string;
  active?: boolean;
  lastLogin?: string;
  phone?: string;
  avatar?: string;
  status?: number; // 0-disabled, 1-enabled
  
  // 添加API响应中的其他字段
  password?: string | null;
  token?: string | null;
  createTime?: string;
  updateTime?: string;
  isDeleted?: number;
  authorities?: {
    authority: string;
  }[];
}

export type ReviewStatus = 'pending' | 'approved' | 'rejected';

export interface TravelSpot {
  id: string;
  title: string;
  content: string;
  location: string;
  images: string[];
  rating: number; // matches 'score' in the API
  recommendationLevel: number; // matches 'recommendLevel' in the API
  visitCount: number; // matches 'viewCount' in the API
  wantToGoCount: number; // matches 'wantGoCount' in the API
  status: ReviewStatus;
  authorId: string;
  author?: User;
  createdAt: string;
  updatedAt: string;
  rejectionReason?: string;
  hasWantToGo?: boolean; // Indicates if current user has marked this spot as "want to go"
}

export interface TravelImage {
  id: string;
  travelInfoId: string;
  imageUrl: string;
  sortOrder: number;
  createTime: string;
}

export interface AuthState {
  user: User | null;
  isAuthenticated: boolean;
  isLoading: boolean;
  token?: string;
}

export interface WantToGo {
  id: string;
  userId: string;
  travelSpotId: string;
  createdAt: string;
}

export interface ReviewHistory {
  id: string;
  travelSpotId: string;
  reviewerId: string;
  reviewer?: User;
  oldStatus: ReviewStatus;
  newStatus: ReviewStatus;
  reason?: string;
  createdAt: string;
}

export interface ApiResponse<T> {
  code: number;
  data: T;
  message: string;
}

export interface PaginatedResponse<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

export interface AuditStats {
  pendingCount: number;
  approvedCount: number;
  rejectedCount: number;
  totalCount: number;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RegisterRequest {
  username: string;
  password: string;
  phone?: string;
  avatar?: string;
}

export interface LoginResponse {
  id: string;
  username: string;
  phone?: string;
  avatar?: string;
  role: string;
  token: string;
}

export interface PasswordChangeRequest {
  oldPassword: string;
  newPassword: string;
}

export interface TravelSpotRequest {
  title: string;
  content: string;
  location: string;
  score: number; // maps to rating in our frontend
  recommendLevel: number; // maps to recommendationLevel in our frontend
  imageUrls?: string[];
}

export interface WantToGoStats {
  totalCount: number;
}
